#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int n = 0, m = 0;
    cin >> n >> m;
    vector<vector<int>> vv(n, vector<int>(m, 0));
    for (int i = 0;i < n;i++)
    {
        for (int j = 0;j < m;j++)
        {
            cin >> vv[i][j];
        }
    }
    //vector<vector<int>> ret(m,vector<int>(n,0));
    for (int i = i = 0;i < m;i++)
    {
        for (int j = 0;j < n;j++)
        {
            cout << vv[j][i] << " ";
        }
        cout << endl;
    }
    return 0;
}
